#pragma once 

#include <iostream>
#include <string>

#include "util.hpp"


namespace ns_log
{
    using namespace ns_util;

    //设置日志等级
    enum
    {
        INFO, 
        DEBUG,
        WARNING,
        ERROR,
        FATAL
    };


    std::ostream &Log(const std::string &level, const std::string &file, int line)
    {
        // 添加日志等级
        std::string massage = "[";
        massage += level;
        massage += "]";

        // 添加报错文件名称
        massage += "[";
        massage += file;
        massage += "]";

        // 添加报错行
        massage += "[";
        massage += std::to_string(line);
        massage += "]";

        // 添加日志时间戳
        massage += "[";
        massage += TimeUtil::GetTimeStamp();
        massage += "]";

        // cout本质，内部是包含缓冲区的
        std::cout << massage; // 不要进行刷新

        return std::cout;
    }


    #define LOG(level) Log(#level, __FILE__, __LINE__)
}
